import Vue from 'vue'
import Router from 'vue-router'
import Index from '@/view/Index'
import Login from '@/view/Login'
import Header from '@/view/Header'
import Menu from '@/view/Menu'
import MenuTab from '@/view/MenuTab'
import Welcome from '@/view/Welcome'
import Footer from '@/view/Footer'

Vue.use(Router)

const routes = [
  {
    path: '/',
    name: 'index',
    component: Index,
    children: [
      {
        path: '/welcome',
        name: 'welcome',
        alias: '/',
        meta: {
          // requireAuth: true //添加该字段，表示进入这个路由是需要登录的
        },
        components: {
          default: Header, // 页面不使用name属性设定时的默认值
          menu: Menu,
          menuTab: MenuTab,
          content: Welcome,
          footer: Footer
        }
      }
    ]
  },
  {
    path: '/login',
    name: 'login',
    component: Login
  }
]

// 定义路由实例
const router = new Router({
  mode: 'history',
  routes
})

// 路由守卫
router.beforeEach((to, from, next) => {
  next()
})

export default router
